package com.example;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 服务端启动类
 * @author: 李涛
 * @version: 2020年07月31日 10:55
 */
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients(clients = RemoteProductService.class)
@RestController
public class ClinetApplicaiton {

	@Bean
	@LoadBalanced
	RestTemplate restTemplate(){
		return  new RestTemplate();
	}

	public static void main(String[] args) {
		SpringApplication.run(ClinetApplicaiton.class,args);
	}

	@Autowired
	private RemoteProductService remoteProductService;

	@GetMapping("/hello")
	public ResponseEntity<String> hello(){
		ResponseEntity<String> hello = remoteProductService.hello();
		return ResponseEntity.ok(hello.getBody());
	}
}
